<template>
  <div id="hk-article">
    <!-- 头部栏 -->
    <div class="Header_bar">
      <van-search
        show-action
        readonly
        placeholder="请输入小区或地址"
        @click="$router.push('/findroom')"
      >
        <template #label>
          <div class="Header_bar_box" @click="toCity">
            <p>{{ $store.state.mycity }}</p>
            <van-icon name="arrow-down" />
          </div>
        </template>
        <template #action>
          <div @click="toMap">
            <van-icon size="25" color="#fff" />
            <span class="icon-ditu iconfont"></span>
          </div>
        </template>
      </van-search>
    </div>
    <!-- 轮播图 -->
    <div class="Swipe">
      <van-swipe :autoplay="3000" class="my-swipe" indicator-color="white">
        <van-swipe-item v-for="item in lbimgs" :key="item.id">
          <img v-lazy="'http://liufusong.top:8080' + item.imgSrc" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <!-- 宫格 -->
    <div class="gongge">
      <van-grid :border="false">
        <van-grid-item @click="$router.push('/findroom')">
          <van-icon
            class="iconfont article-iconfont"
            class-prefix="icon-pinzhizhengzu"
          ></van-icon>
          <p>整租</p>
        </van-grid-item>
        <van-grid-item @click="$router.push('/findroom')">
          <van-icon
            class="iconfont article-iconfont"
            class-prefix="icon-hezu"
          ></van-icon>
          <p>合租</p>
        </van-grid-item>
        <van-grid-item @click="toMap">
          <van-icon
            class="iconfont article-iconfont"
            class-prefix="icon-dituzhaofang"
          ></van-icon>
          <p>地图找房</p>
        </van-grid-item>
        <van-grid-item @click="$router.push('/findroom')">
          <van-icon
            class="iconfont article-iconfont"
            class-prefix="icon-woyaochuzu"
          ></van-icon>
          <p>去出租</p>
        </van-grid-item>
      </van-grid>
    </div>
    <!-- 租房小组 -->
    <div class="zhufangxz">
      <div class="biao">
        <h3>租房小组</h3>
        <p>更多</p>
      </div>
      <div class="meirong">
        <van-grid
          :border="false"
          :column-num="2"
          direction="horizontal"
          gutter="10"
        >
          <van-grid-item v-for="item in zfdata" :key="item.id">
            <div class="zf-img">
              <img v-lazy="'http://liufusong.top:8080' + item.imgSrc" />
            </div>
            <div class="tex">
              <h4>{{ item.title }}</h4>
              <p>{{ item.desc }}</p>
            </div>
          </van-grid-item>
        </van-grid>
      </div>
    </div>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  name: 'hk-article',
  data() {
    return {
      lbimgs: [],
      zfdata: []
    }
  },
  async created() {
    const res = await request({
      url: '/home/swiper',
      method: 'get'
    })
    console.log(res)
    this.lbimgs = res.body
    const zfres = await request({
      url: '/home/groups',
      method: 'get'
    })
    console.log(zfres)
    this.zfdata = zfres.body
  },
  methods: {
    toCity() {
      this.$router.push({
        path: '/city'
      })
    },
    toMap() {
      this.$router.push({
        path: '/map'
      })
    }
  }
  // mounted() {
  //   console.log(this.$store)
  // }
}
</script>
<style scoped lang="less">
#hk-article {
  position: relative;
  // 头部栏
  .Header_bar {
    position: absolute;
    z-index: 99999;
    top: 15px;
    left: 0;
    width: 100%;
    .van-search {
      background-color: rgba(255, 255, 255, 0);
      padding: 5px 20px 5px 20px;
    }
    .van-search__content {
      padding-left: 8px;
    }
    .Header_bar_box {
      display: flex;
      justify-content: space-between;
      align-items: center;
      p {
        margin-right: 5px;
      }
    }
    .icon-ditu {
      font-size: 32px;
      color: #fff;
      line-height: 20px;
    }
    .van-search__action {
      line-height: 0;
      padding: 5px;
      padding-right: 0;
    }
    /deep/.van-field__left-icon {
      border-left: 1px solid #e3e3e3;
      // height: ;
    }
    /deep/.van-icon-search:before {
      padding-left: 6px;
    }
  }
  // 轮播图
  .my-swipe {
    img {
      width: 100%;
      height: 212px;
    }
    .van-swipe-item {
      color: #fff;
      font-size: 20px;
      // line-height: 212px;
      text-align: center;
      background-color: #39a9ed;
    }
  }
  // 宫格
  .gongge {
    height: 122px;
    background-color: #fff;
    p {
      font-size: 12px;
    }
    .article-iconfont {
      color: #10b36f;
      background-color: #f2fbf7;
      border-radius: 50%;
      font-size: 45px;
      // padding-bottom: 10px;
      padding: 6px;
      margin-bottom: 5px;
    }
  }

  // 租房小组
  .zhufangxz {
    background-color: #f6f5f6;
    width: 100%;
    padding-bottom: 10px;
    .biao {
      display: flex;
      justify-content: space-between;
      background-color: rgba(255, 255, 255, 0);
      width: 100%;
      padding: 10px;
      h3 {
        font-size: 16px;
      }
      p {
        font-size: 12px;
        color: #999;
      }
    }
    .meirong {
      .zf-img {
        width: 50px;
        height: 50px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .tex {
        width: 70px;
        height: 50px;
        font-size: 14px;
        line-height: 25px;
        margin: 0 10px 0 10px;
      }
    }
    .van-grid {
      margin-bottom: 50px;
    }
  }
}
.van-field__control {
  height: 34px;
}

/deep/ .van-grid-item__content {
  padding-top: 20px;
  padding-bottom: 20px;
}
</style>
